<?

	$postUrl = $this->getConfirmUrl();
	$shopUrl = $this->getShopUrl();
	$cartUrl = $this->getCartUrl();
	
 	$currency = $this->getCurrency();
 	$currencySign = $this->getCurrencySign();
 	
 	//if we have only one order
 	if (1 < count($this->orderContainer->orderItems()) ){
 		$removeItemReturnUrl= $this->getCartUrl();
 	} else {
 		$removeItemReturnUrl = $this->getShopUrl();
 	}
 	
 	$ik = $this->orderContainer->valueForKey('invalidKeys');
 	
?> 
<table align="center" cellpadding="0" cellspacing="0" id="purchaseDetails" >
  <tr>
    <td valign="middle" class="tableCell item"><strong>Item</strong></td>
    <td align="right" valign="middle" class="tableCell cartprice"><strong>Price </strong></td>
    <td align="right" valign="middle" class="tableCell qty"><strong>Qty</strong></td>
    <td align="right" valign="middle" class="tableCell subtotal"><strong>Sub-total</strong></td>
    <td align="right" valign="middle" class="tableCellR remove">&nbsp;</td>
  </tr>
<?


	foreach ($this->orderContainer->orderItems() as $oi) {
		
	
	//	if(isset($this->orderContainer) && !is_null($this->orderContainer)){
			 //$orderItems = $this->orderContainer->orderItems();
			 		 
			 //foreach($orderItems as $orderItem){
				//myPrintR($orderItem);	 
				$pid = $oi->valueForKey('productId');
				$oid = $oi->valueForKey('id');
				$subTotal = $oi->valueForKey('subTotal');
				$quantity = $oi->valueForKey('quantity');
				$price = $oi->valueForKey('price');
				
				//$imgSrc = "/html/blob.php?documentCode=" . $pid . "&amp;elementId=11142";		 	
			 	// we need to get the currency and the price and what not..
			 	$imgSrc = $oi->valueForKey("productInvoiceImageUrl");
			 	$itemUrl = $oi->valueForKey("productUrl");
			 	$itemDescription = $oi->valueForKey("productInvoiceDescription");
?>  
  <tr>
    <td valign="middle" class="tableCell item"><a href="<?= $itemUrl ?>" ><img src="<?= $imgSrc; ?>" class="cartImg" alt=""/></a> <a href="<?= $itemUrl ?>"><?= $itemDescription ?></a></td>
    <td align="right" valign="middle" class="tableCell cartprice">  <?= $currencySign ?><? printf("%01.2f",  $price);?><?= " " . $currency ?> </td>
    <td align="right" valign="middle" class="tableCell qty"><?= $quantity ?></td>
    <td align="right" valign="middle" class="tableCell subtotal"><span class="subTotal"><?= $currencySign ?><? printf("%01.2f",  $subTotal );?> <?= " " . $currency ?> </span></td>
    <td align="right" valign="middle" class="tableCellR remove"><a title="Remove From Order" href="?deleteItemFromContainer=<?= $oid; ?>&amp;returnUrl=<?=urlencode($removeItemReturnUrl)?>" ><img src="/images/cartRemove.gif" alt="Remove item" /></a></td>
  </tr>
<?
			 	
	}
		
		
		
		//nothing for shipping???
		//free on this site..
?>  

  <tr>
  		<td colspan="3" align="right" class="tableCell shippingFee">Shipping Fee 
  		</td>
	  <td align="right" class="tableCell">
	     <div id="cartShipping"><?= $currencySign ?><? printf("%01.2f",  $this->orderContainer->valueForKey('shippingPrice'));?> <?= " " . $currency ?></div></td> 
	  </td>
	  <td class="tableCellR">&nbsp;
	  </td>
  </tr>
    
  <tr>
    	<td colspan="3" align="right" class="tableCell total">Total 
  		</td>
	  <td align="right" class="tableCell">
	     <div id="cartTotal"><?= $currencySign ?><? printf("%01.2f",  $this->orderContainer->valueForKey('totalPrice'));?> <?= " " . $currency ?></div></td> 
	  </td>
	  <td class="tableCellR">&nbsp;
	  </td>
  </tr>
  
  <tr>
    <td colspan="5" valign="middle" class="tableCellBR" align="right">
    
    <div id="cartControl"> <a href="?orderStep=cancelOrder"><img src="/images/cartClear.gif" alt="Clear your entire order" /></a>&nbsp;&nbsp;<a href="<?= $shopUrl ?>"><img src="/images/cartContinue.gif" alt="Continue looking" /></a> </div>
    </td>
  </tr>
  
</table>		
		
		
		
		
		
		




<div class="divider"></div>




  


 <form id="cartForm" name="cartForm" method="post" action="<?= $postUrl ?>" enctype="multipart/form-data">
			 
			  <table cellpadding="0" cellspacing="0" id="shippingDetails" >
                      <tr>
                        <td colspan="2" align="left" valign="top"><h4>Your Details:</h4>						</td>
                      </tr>

                      <tr>
                        <td width="155" align="right" valign="middle" class="tableCell" >First Name:<span class="asterix">*</span> </td>
                        <td width="196" valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('firstName') ?>" id="firstName" value="<?= $this->orderContainer->valueForKey('firstName') ?>"  size="60" maxlength="100" />                        
<?
		if (!$this->orderContainer->isKeyValid('firstName')){
?> 					                  	
	      <br /><span class="orderValidationError" > First Name is a Required Field.</span>
<?
		}
?>                        
                        
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="tableCell" >Last Name:<span class="asterix">*</span> </td>

                        <td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('lastName') ?>" id="lastName" value="<?= $this->orderContainer->valueForKey('lastName') ?>"  size="60" maxlength="100" />                       
<?
		if (!$this->orderContainer->isKeyValid('lastName')){
?> 					                  	
	      <br /><span class="orderValidationError" > Last Name is a Required Field.</span>
<?
		}
?>                        
                        
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="tableCell" >Email:<span class="asterix">*</span> </td>
                        <td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('email') ?>" id="email" value="<?= $this->orderContainer->valueForKey('email') ?>"  size="60" maxlength="100" />                        
<?
		if (!$this->orderContainer->isKeyValid('email')){
 			

?> 					                  	
	      <br /><span class="orderValidationError" >Email Address <?= $ik['email'] ?>.</span>
<?
		}
?>

                        </td>
                      </tr>

                      <tr>
                        <td align="right" valign="middle" class="tableCell">Verify Email:<span class="asterix">*</span> </td>
                        <td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('verifyEmail') ?>" id="verifyEmail" value="<?= $this->orderContainer->valueForKey('verifyEmail') ?>" size="60" maxlength="100" />                        
<?
 		if (!$this->orderContainer->isKeyValid('verifyEmail')){

?> 					                  	
	      <br /><span class="orderValidationError" > Verify Email Address <?= $ik['verifyEmail'] ?>.</span>
<?
 		}
?>                        
                        
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="tableCell">Ph:<span class="asterix">*</span><br />                        </td>

                        <td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('phone') ?>" id="phone" value="<?= $this->orderContainer->valueForKey('phone') ?>" size="60" maxlength="100" />                        
<?
		if (!$this->orderContainer->isKeyValid('phone')){
?> 					                  	
	      <br /><span class="orderValidationError" > Phone is a Required Field.</span>
<?
		}
?>                        
                        
                        </td>
                      </tr>
					  <tr>
					    <td align="right" valign="middle" class="tableCell"><strong>Where did you hear about us?</strong></td>
					    <td valign="middle" class="tableCellR">
<?
	$hearAboutUsKey = $this->orderContainer->keyForField('hearAboutUs');
?>					    
					    	<select name="<?= $hearAboutUsKey ?>" id="hearAboutUs">
						    	<option></option>
<?
	$hearAboutUsOptions = array("Search Engine","Magazine","Friend","Store","Other");
	foreach ($hearAboutUsOptions as $hearAboutUsOption){
?>
<option <?= ($this->orderContainer->valueForKey('hearAboutUs') == $hearAboutUsOption ) ? "selected=\"selected\"" : "" ?> ><?= $hearAboutUsOption ?></option>
<?
	}
?>
					    	</select>
                     

					    
					    </td>
			      </tr>
                      
	    </table>		  
					  
					  
					  
					  
				<table cellpadding="0" cellspacing="0" id="shippingAddress">
					  <tr valign="top">
						<td colspan="2"><h4>Delivery Address:</h4></td>
					  </tr>
					  <tr>
						<td align="right" valign="middle" class="tableCell" >Address Line 1:<span class="asterix">*</span> </td>
						<td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('street') ?>" id="street" value="<?= $this->orderContainer->valueForKey('street') ?>" size="60" maxlength="100" />                        
<?
		if (!$this->orderContainer->isKeyValid('street')){
?> 					                  	
	      <br /><span class="orderValidationError" > Street is a Required Field.</span>
<?
		}
?>
						</td>
					  </tr>
					  <tr>
						<td width="136" align="right" valign="middle" class="tableCell" >Address Line 2:</td>
						<td valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('suburb') ?>" id="suburb" value="<?= $this->orderContainer->valueForKey('suburb') ?>" size="60" maxlength="100" />						
						
						</td>
					  </tr>
					  <tr>
						<td align="right" valign="middle" class="tableCell" >City:<span class="asterix">*</span></td>
						<td width="202" valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('city') ?>" id="city" value="<?= $this->orderContainer->valueForKey('city') ?>" size="60" maxlength="100" />                        
<?
		if (!$this->orderContainer->isKeyValid('city')){
?> 					                  	
	      <br /><span class="orderValidationError" > City is a Required Field.</span>
<?
 		}
?>	
						</td>
					  </tr>
					  <tr>
						<td align="right" valign="middle" class="tableCell" >State /  Region:</td>
						<td width="202" valign="middle" class="tableCellR"><input type="text" name="<?= $this->orderContainer->keyForField('state') ?>" id="state" value="<?= $this->orderContainer->valueForKey('state') ?>" size="60" maxlength="100" />						</td>
					  </tr>					  
					  <tr>
						<td align="right" valign="middle" class="tableCell" >ZIP/Postal Code:<span class="asterix"></span></td>
						<td width="202" valign="middle" class="tableCellR">
						<input type="text" name="<?= $this->orderContainer->keyForField('zip') ?>" id="zip" value="<?= $this->orderContainer->valueForKey('zip') ?>" size="60" maxlength="100" />						
<?
		if (!$this->orderContainer->isKeyValid('zip')){
?> 					                  	
	      <br /><span class="orderValidationError" > ZIP/Postal Code is a Required Field.</span>
<?
 		}
?>							
						
						</td>
					  </tr>
					
					  <tr>
					    <td align="right" valign="top" class="tableCell"><strong>Country:</strong><span class="asterix">*</span></td>
					    <td valign="top" class="tableCellR">
					      <? /* <select name="cd261d34_country" id="country"  onchange="document.forms['shippingForm'].submit();">
                            <option value="140"  selected="selected">New Zealand - North Island</option>
                            <option value="249" >New Zealand - South Island</option>
                          </select> */ ?>
<?php 
		$countries = $this->orderContainer->valueForKey('countryList');
?>
					      <select name="<?= $this->orderContainer->keyForField('country') ?>" id="country" class="body">
            

<?  
		//$countryTableWriter = new CmsTableWriter('country',$db);
		//$countryTableWriter->resetCustomIterator(" WHERE iso_3166_1_alpha_2 <> '' AND iso_3166_1_alpha_2 <> 'ZZ' ORDER BY name ASC "); 
		//while (($row = $countryTableWriter->nextItem())){

		foreach($countries as $row){
			//clean those that could have cruft..  
			$name = magicClean($row->name);
			$id = $row->id;
			//$countrycode = $row->iso_3166_1_alpha_2;
?>	      
                <option value="<?= $id ?>" <? if($id ==  $this->orderContainer->valueForKey('country') ) echo " selected=\"selected\""; ?>><?= $name ?></option>
<?
		} 
?>
                  </select>
<?
		if (!$this->orderContainer->isKeyValid('country')){
?> 					                  	
	      <br /><span class="orderValidationError"  > Country is a Required Field.</span>
<?
		}
?>	    </td>
			      </tr>
					  
					  <tr>
						<td align="right" valign="top" class="tableCell"><strong>Comments:</strong><br /></td>
						<td valign="top" class="tableCellR"><textarea name="<?= $this->orderContainer->keyForField('comments') ?>" id="comments" cols="55" rows="7"><?= magicClean($this->orderContainer->valueForKey('comments')) ?></textarea>
						</td>
					  </tr>
				</table>	
		
<div class="clear"></div>

					
					<div id="purchaseSubmit">

						<div id="submitArea">
						<div id="cartTermsAgree">
							 I have read and agree to the Terms &amp; Conditions <input type="checkbox" name="<?= $this->orderContainer->keyForField('termsAgree') ?>" id="termsAgree" <? if ( $this->orderContainer->valueForKey('termsAgree')) { echo "checked=\"checked\"";} ?> value='true' />
<?
		if (!$this->orderContainer->isKeyValid('termsAgree')){
?> 					                  	
	      <br /><span class="orderValidationError" > You must accept the terms and conditions.</span>
<?
 		}
?>							
						</div>
						
						<input name="image" type="image" class="confirm" src="/images/cartSubmit.gif" alt="Confirm Order"  />
						<a id="showTerms" href="#Terms" rel="ibox"></a>
						
						</div>

						
					</div>
						
						
								  
	  </form>
	  
	 
								
								
<div class="divider"></div>	